package com.genius.action;

import java.util.List;

import com.genius.core.manager.StudentManager;
import com.genius.model.Batch;
import com.genius.model.Student;
import com.opensymphony.xwork.ActionSupport;

public class BatchAction extends ActionSupport
{
    
	private static final long serialVersionUID = 1L;

	private Batch batch = null;
    
    private String batchId = null;

    private StudentManager studentManager = null;
    
    private List batchList = null;
    
    private List ciList = null;
        
        
    /**
     * @return Returns the student.
     */
    public Batch getBatch()
    {
        return batch;
    }

    /**
     * @param student The student to set.
     */
    public void setBatch(Batch batch)
    {
        this.batch = batch;
    }

    public BatchAction()
    {
        this.batch = new Batch();
    }

    /**
     * @see com.opensymphony.xwork.ActionSupport#execute()
     */
    public String showAddBatchForm() throws Exception
    {
        //Returns page with student entry form
        ciList = this.studentManager.getTeacherList();
        return this.SUCCESS;
    }
    
    /**
     * @see com.opensymphony.xwork.ActionSupport#execute()
     */
    public String addBatch() throws Exception

    {
        // Add new student to database.
        studentManager.addBatch(batch);
        this.batchList = this.studentManager.getBatchList(-1);
        System.out.println("Action batchList" + batchList.size());
        return this.SUCCESS;
    }
    
    
    /**
     * @see com.opensymphony.xwork.ActionSupport#execute()
     */
    public String viewBatch() throws Exception

    {
        // Add new student to database.
        batch = studentManager.getBatch(batchId);
        
        //this.batchList = this.studentManager.getBatchList(-1);
        //System.out.println("Action batchList" + batchList.size());
        return this.SUCCESS;
    }

    /**
     * @see com.opensymphony.xwork.ActionSupport#execute()
     */
    public String editBatchDetails() throws Exception

    {
        // Add new student to database.
        batch = studentManager.getBatch(batchId);
        ciList = this.studentManager.getTeacherList();
        //this.batchList = this.studentManager.getBatchList(-1);
        //System.out.println("Action batchList" + batchList.size());
        return this.SUCCESS;
    }

    
    /**
     * @return Returns the studentManager.
     */
    public StudentManager getStudentManager()
    {
        return studentManager;
    }

    /**
     * @param studentManager The studentManager to set.
     */
    public void setStudentManager(StudentManager studentManager)
    {
        this.studentManager = studentManager;
    }

    /**
     * @param studentManager The studentManager to set.
     */
    public void selectBatch(StudentManager studentManager)
    {
        this.studentManager = studentManager;
    }

    /**
     * @return Returns the batchList.
     */
    public List getBatchList()
    {
        return this.batchList;
    }

    /**
     * @param batchList The batchList to set.
     */
    public String showBatchList()
    {
        this.batchList = this.studentManager.getBatchList(1);
        return this.SUCCESS;
    }

    /**
     * @param batchList The batchList to set.
     */
    public void setBatchList(List batchList)
    {
        this.batchList = batchList;
        
    }

    /**
     * @return Returns the batchId.
     */
    public String getBatchId()
    {
        return batchId;
    }

    /**
     * @param batchId The batchId to set.
     */
    public void setBatchId(String batchId)
    {
        this.batchId = batchId;
    }

    /**
     * @return Returns the ciList.
     */
    public List getCiList()
    {
        return ciList;
    }

    /**
     * @param ciList The ciList to set.
     */
    public void setCiList(List ciList)
    {
        this.ciList = ciList;
    }


}
